/**  
* @Title: WechatRechargeController.java
* @Package com.hjb.service.controller.Wechat
* @author <a href="mailto:125671254@qq.com">Pan Xinwen</a>panxinwen
* @date 2018年1月17日 下午11:17:48
* @version V1.0  
*/ 
package com.hjb.service.controller.Wechat;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.hjb.service.Wechat.WechatRechargeService;
import com.hjb.service.annotation.LogInfo;
import com.hjb.service.annotation.LogType;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
* @ClassName: WechatRechargeController
* @Description: TODO(用户充值)
* @author <a href="mailto:125671254@qq.com">Pan Xinwen</a>panxinwen
* @date 2018年1月17日 下午11:17:48
*/
@RestController
@RequestMapping("/Wechat/recharge")
@Api(value="/Wechat/recharge",description="公众号端租户充值"	)
public class WechatRechargeController {
	
	@Autowired
	private WechatRechargeService wechatRechargeService;
	
	/**
	 * 获取充值验证码
	 * @param request
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	@LogInfo(logType=LogType.查询,operationContent="充值获取 验证码")
	@PostMapping("/getAuthCode")
	@ResponseBody
	@ApiOperation(value="充值获取 验证码", notes="充值获取 验证码")
	@ApiImplicitParams({ 
		@ApiImplicitParam(paramType = "query", dataType = "String", name = "userId", value = "用户id", required = false),
		@ApiImplicitParam(paramType = "query", dataType = "String", name = "amount", value = "充值金额", required = false)})
	public ResponseEntity getAuthCode(
			@RequestParam(value = "userId", required = true) String userId,
			@RequestParam(value = "instalmentId", required = true) String instalmentId,
			@RequestParam(value = "amount", required = true) String amount) {

		Map<String, Object> resMap = wechatRechargeService.getAuthCode(userId, amount,instalmentId);

		return ResponseEntity.ok(resMap);
	}
	
	/**
	 * 确认充值
	 * @param request
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	@LogInfo(logType=LogType.查询,operationContent="确认充值")
	@PostMapping("/authPayConfirm")
	@ResponseBody
	@ApiOperation(value="确认充值", notes="确认充值")
	@ApiImplicitParams({ 
		@ApiImplicitParam(paramType = "query", dataType = "String", name = "userId", value = "userId", required = true),
		@ApiImplicitParam(paramType = "query", dataType = "String", name = "orderId", value = "充值流水号", required = true),
		@ApiImplicitParam(paramType = "query", dataType = "String", name = "smsCode", value = "短信验证码", required = true)})
	public ResponseEntity authPayConfirm(
			@RequestParam(value = "userId", required = true) String userId,
			@RequestParam(value = "orderId", required = true) String orderId,
			@RequestParam(value = "smsCode", required = true) String smsCode){
		
		Map<String, Object> resMap = wechatRechargeService.rechargeConfirm(orderId, smsCode);
		
		return ResponseEntity.ok(resMap);
	}

}
